package com.araaya.eslimsmobile.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import android.os.Environment;

public class PropertyReader {

	private static String PROPERTY_PATH = Environment.getExternalStorageDirectory().toString() + "/eLand/properties/server_url";
	private static File propertyFile;
	
	
	public static String loadProperties() throws FileNotFoundException{
		propertyFile = new File(PROPERTY_PATH);
		StringBuilder contents = new StringBuilder();
		if(propertyFile.exists() && propertyFile.isFile()){
			 try {
				BufferedReader input =  new BufferedReader(new FileReader(propertyFile));
				try {
			        String line = null;
			        while (( line = input.readLine()) != null){
			          contents.append(line);
			          contents.append(System.getProperty("line.separator"));
			        }
			     }finally {
			        input.close();
			     }
				return contents.toString().trim();
			} catch (IOException e) {
				throw new FileNotFoundException();
			}
		}else{
			throw new FileNotFoundException();
		}
	}
}
